import React from 'react';
import {GTable} from 'geminis-react';

export default () => {
  const schema = {
    headerTitle: '数据查询',
    data: {
      url: '/api/users',
      filter: {
        type: 'search'
      }
    },
    pagination: {
      defaultPageSize: 5,
    },
    search: {
      labelWidth: 'auto',
    },
    columns: [
      {
        title: 'Name',
        dataIndex: 'name',
        filterType: 'text',
      },
      {
        title: 'Age',
        dataIndex: 'age',
        search: false,
      },
      {
        title: 'Title',
        dataIndex: 'data',
        filterType: 'date',
        render: (data) => data.title,
      },
      {
        title: 'Birthday',
        dataIndex: 'birthday',
        valueType: 'date',
      },
      {
        title: '已停用',
        dataIndex: 'deleted',
        valueType: 'select',
        initialValue: false,
        formItemProps: {
          label: '状态',
          name: 'deleted1'
        },
        fieldProps: {
          options: [
            {label: '全部', value: undefined},
            {label: '停用', value: true},
            {label: '在用', value: false},
          ]
        },
        valueEnum: {
          true: {
            text: '是'
          },
          false: {
            text: '否'
          }
        }
      }
    ],
  };

  return (
    <GTable schema={schema}/>
  );
};
